﻿using BCCommon;
using BCCommon.TMS.ManageFeeBusiness;
using BCDto.TMS.PlatformManageFee.PlatformManageFeeConfig;
using BCService.TMS.PlatformManageFee.PlatformManageFeeConfig;
using BCTMSRESTful.Configs;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BCTMSRESTful.Controllers.Management.TMS.PlatformManageFee
{
    /// <summary>
    /// 平台管理费配置
    /// </summary>
    [Route("api/v1/sim/[controller]")]
    [ApiExplorerSettings(GroupName = "TMSAdmin")]
    public class PlatformManageFeeConfigController : ManagementBaseController
    {
        private readonly IPlatformManageFeeConfigService platformManageFeeConfigService;

        public PlatformManageFeeConfigController(IPlatformManageFeeConfigService platformManageFeeConfigService)
        {
            this.platformManageFeeConfigService = platformManageFeeConfigService;
        }

        #region PUT 修改   
        /// <summary>
        /// 修改平台管理费配置记录
        /// </summary>
        /// <param name="platformManageFeeConfigId">平台管理费配置Id</param>
        /// <param name="dto">平台管理费配置数据修改模型</param>
        /// <returns></returns>
        [Log("修改平台管理费配置记录")]
        [HttpPut("{platform_manage_fee_config_id}")]
        [ProducesResponseType(typeof(PlatformManageFeeConfigDto), 200)]
        public IActionResult Put([FromRoute(Name = "platform_manage_fee_config_id")] long platformManageFeeConfigId, [FromBody] PlatformManageFeeConfigPutDto dto)
        {
            var result = this.platformManageFeeConfigService.Update(this.Admin, platformManageFeeConfigId, dto);
            return this.Ok(result);
        }
        #endregion

        #region 删除  
        /// <summary>
        /// 删除平台管理费配置记录
        /// </summary>
        /// <param name="platformManageFeeConfigId">平台管理费配置ID</param>
        /// <returns></returns>
        [Log("删除平台管理费配置记录")]
        [HttpDelete("{platform_manage_fee_config_id}")]
        [ProducesResponseType(typeof(NoContentResult), 204)]
        public IActionResult Delete([FromRoute(Name = "platform_manage_fee_config_id")] long platformManageFeeConfigId)
        {
            this.platformManageFeeConfigService.Delete(this.Admin, platformManageFeeConfigId);
            return NoContent();
        }
        #endregion

        #region GetByID     
        /// <summary>
        /// 获取一条平台管理费配置记录
        /// </summary>
        /// <param name="platformManageFeeConfigId">平台管理费配置ID</param>
        /// <returns></returns>
        [HttpGet("{platform_manage_fee_config_id}")]
        [ProducesResponseType(typeof(PlatformManageFeeConfigDto), 200)]
        public IActionResult Get([FromRoute(Name = "platform_manage_fee_config_id")] long platformManageFeeConfigId)
        {
            var result = this.platformManageFeeConfigService.GetById(platformManageFeeConfigId);
            return this.Ok(result);
        }
        #endregion

        #region Query 
        /// <summary>
        /// 查询平台管理费配置
        /// </summary>
        /// <param name="companyId">公司Id</param>
        /// <param name="manageFeeBusinessType">管理费业务类型</param>
        /// <param name="pageIndex">页号</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(PageableList<PlatformManageFeeConfigViewDto>), 200)]
        public IActionResult Query([FromQuery(Name = "company_id")] int? companyId,
            [FromQuery(Name = "manage_fee_business_type")] TMSManageFeeBusinessType? manageFeeBusinessType,
            [FromQuery(Name = "page_index")] int pageIndex = 1,
            [FromQuery(Name = "page_size")] int pageSize = 10)
        {
            var result = this.platformManageFeeConfigService.GetList(this.Admin, companyId, manageFeeBusinessType, pageIndex, pageSize);
            return this.Ok(result);
        }
        #endregion
    }
}
